<%@page import="java.util.List"%>
<%@page import="edu.scau.hibernate.model.User"%>
<%@page import="edu.scau.hibernate.service.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" errorPage="error.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
#p{
text-align:left;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>index</title>
<% UserService serviceImpl;
List<User> list = null;
   User user = (User)session.getAttribute("user");//获取登录用户
%>
</head>
<body>

     <%if(user==null) response.sendRedirect("login.html");//没登陆自动跳转登陆界面  %>
     <div align="right">欢迎 <%=user.getUserName() %>访问 </div> 
            <br> 
<center>
    <form name="index" action="index.jsp" method="get">
    <table border="1">
    <tr>
    <td>Id</td>
    <td>用户名</td>
    <td>性别</td>
    <td>年龄</td>
    <td>邮箱</td>
    <td>注册时间</td>    
    </tr>
    <% 
    serviceImpl = new UserServiceImpl();
       try{
    	   list = serviceImpl.findAllUser();
       }catch(Exception e){
    	   e.printStackTrace();
       }
       for(int i = 0;i<list.size();i++){
    	   User u = list.get(i);
       %>
       <tr>
       <td><%=u.getUserId() %></td>
       <td><%=u.getUserName() %></td>
       <td><%=u.getGender() %></td>
       <td><%=u.getAge() %></td>
       <td><%=u.getEmail() %></td>
       <td><%=u.getRegDatetime() %></td>
       </tr>
    <%	   
       }
    %>
    </table>
    <br>
    <U><a href="update1.jsp">用户修改</a></U><!-- 跳转用户修改页面 -->
    </form>
</center>
</body>
</html>
